package androidlab.sprintingsquirrel.credits;

import org.andengine.entity.scene.background.Background;
import org.andengine.entity.text.Text;
import org.andengine.util.color.Color;
import androidlab.sprintingsquirrel.BaseScene;
import androidlab.sprintingsquirrel.ResourceManager;
import androidlab.sprintingsquirrel.SceneManager;
import androidlab.sprintingsquirrel.SceneManager.SceneType;


public class CreditsScene extends BaseScene {
	
	private Text programmerText;
	private Text artDesignText;
	private Text animationsText;
	private Text engineNameText;
	private Text andengineNameText;
	private Text twoNamesText1;
	private Text twoNamesText2;
	private Text oneNameText;
	
	@Override
    public void createScene() {
        setBackground(new Background(Color.BLACK));
        createText(0.3f, 0.25f);
        setCreditsText(0,30,150,180,300,330,450,480);  
    }

    @Override
    public void onBackKeyPressed() {
    	SceneManager.getInstance().loadMenuScene();
    }

    @Override
    public SceneType getSceneType() {
    	return SceneType.CREDITS;
    }

    @Override
    public void disposeScene() {
    	
    }
    
    private void createText(float titelScale, float nameScale) {
    	programmerText = new Text(0, 0, ResourceManager.getInstance().font_credits_titel, "- Programmers -", vbom);
    	programmerText.setSkew(0, 0);
    	programmerText.setScale(titelScale);
    	
    	artDesignText = new Text(0, 0, ResourceManager.getInstance().font_credits_titel, "- Art Design -", vbom);
    	artDesignText.setSkew(0, 0);
    	artDesignText.setScale(titelScale);
    	
    	animationsText = new Text(0, 0, ResourceManager.getInstance().font_credits_titel, "- Animations -", vbom);
    	animationsText.setSkew(0, 0);
    	animationsText.setScale(titelScale);
    	
    	engineNameText = new Text(0, 0, ResourceManager.getInstance().font_credits_titel, "- Powered by -", vbom);
    	engineNameText.setSkew(0, 0);
    	engineNameText.setScale(nameScale);
    	
    	andengineNameText = new Text(0, 0, ResourceManager.getInstance().font_credits_names, "Andengine", vbom);
    	andengineNameText.setSkew(0, 0);
    	andengineNameText.setScale(nameScale);
    	
    	twoNamesText1 = new Text(0, 0, ResourceManager.getInstance().font_credits_names, "Thomas Schrader and Dmitrij Menschikow", vbom);
    	twoNamesText1.setSkew(0, 0);
    	twoNamesText1.setScale(nameScale);
    	
    	twoNamesText2 = new Text(0, 0, ResourceManager.getInstance().font_credits_names, "Thomas Schrader and Dmitrij Menschikow", vbom);
    	twoNamesText2.setSkew(0, 0);
    	twoNamesText2.setScale(nameScale);
    	
    	oneNameText = new Text(0, 0, ResourceManager.getInstance().font_credits_names, "Juanjuan Yin", vbom);
    	oneNameText.setSkew(0, 0);
    	oneNameText.setScale(nameScale);
    	
    	attachChild(programmerText);
    	attachChild(artDesignText);
    	attachChild(animationsText);
    	attachChild(engineNameText);
    	attachChild(andengineNameText);
    	attachChild(twoNamesText1);
    	attachChild(twoNamesText2);
    	attachChild(oneNameText);
    }
    
    private void setCreditsText(int yPosProg, int yPos2Names1, int yPosArt, int yPos2Names2, int yPosAnima, int yPos1Name, int yPosEngine, int yPosAndengine){
    	programmerText.setPosition(camera.getCenterX()-programmerText.getWidth()/2, yPosProg);
    	programmerText.setText("- Programmers -");
    	twoNamesText1.setPosition(camera.getCenterX()-twoNamesText1.getWidth()/2, yPos2Names1);
    	twoNamesText1.setText("Thomas Schrader and Dmitrij Menschikow");
    	
    	artDesignText.setPosition(camera.getCenterX()-artDesignText.getWidth()/2, yPosArt);
    	artDesignText.setText("- Art Design -");
    	twoNamesText2.setPosition(camera.getCenterX()-twoNamesText1.getWidth()/2, yPos2Names2);
    	twoNamesText2.setText("Thomas Schrader and Dmitrij Menschikow");
    	
    	animationsText.setPosition(camera.getCenterX()-animationsText.getWidth()/2, yPosAnima);
    	animationsText.setText("- Animations -");
    	oneNameText.setPosition(camera.getCenterX()-oneNameText.getWidth()/2, yPos1Name);
    	oneNameText.setText("Juanjuan Yin");

    	engineNameText.setPosition(camera.getCenterX()-engineNameText.getWidth()/2, yPosEngine);
    	engineNameText.setText("- Powered by -");
    	andengineNameText.setPosition(camera.getCenterX()-andengineNameText.getWidth()/2, yPosAndengine);
    	andengineNameText.setText("AndEngine");
    	
    }

}
